﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using BlawkayEngine;

namespace BlawkayEngine.ScreenSystem
{
    public class SplashScreen : Screen
    {
        public SplashScreen(Game oGame, float oTime)
            : base(oGame)
        {
            _TimeToStayAlive = oTime;
            TransitionRate = (1f / 60f) * 0.75f;
        }

        public override void Update(ScreenManager oManager)
        {
            // If the Screen is Transitioned
            if (Active)
            {
                if (Alive)
                    _Timer += (float)GameInfo.GameTime.ElapsedGameTime.TotalSeconds;
            }
        }

        public override void Draw(ScreenManager oManager, SpriteBatch oSB)
        {
            Vector2 oCenter = new Vector2(GameInfo.Resolution.Center.X, GameInfo.Resolution.Center.Y);
            Vector2 oOrigin = new Vector2(Texture.Width / 2, Texture.Height / 2);

            oSB.Draw(Texture, oCenter, null, SplashColor, 0.0f, oOrigin, 1.0f, SpriteEffects.None, 1.0f);
        }

        public override void ActionWhenFullyAdded(ScreenManager oManager)
        {
        }

        public override void ActionWhenFullyRemoved(ScreenManager oManager)
        {
        }

        public Texture2D Texture
        {
            get { return _Texture; }
            set { _Texture = value; }
        }

        public bool Alive
        {
            get { return _Timer < _TimeToStayAlive; }
        }

        public bool Dead
        {
            get { return Alive == false; }
        }

        public Color SplashColor
        {
            get { return _Color; }
            set { _Color = value; }
        }

        float _Timer;
        float _TimeToStayAlive;
        Texture2D _Texture;
        Color _Color;
    }
}
